package com.yiranLTD;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yiranLTD.mapper.batisPlusMapper;
import com.yiranLTD.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class testApplication {

    //注入Mapper
    @Autowired
    private batisPlusMapper  mapper;
    @Test
    public void myBatisPlusTest(){
        //1：查询所有
        List<User> users = mapper.selectList(null);
        users.forEach(System.out::println);
        //2 创建一个选择器
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
            //配置选择器
        queryWrapper.select(User::getId, User::getName, User::getAge)
                .ge(User::getAge, 50);
        List<User> users1 = mapper.selectList(queryWrapper);
        if ((users1!=null && !users1.isEmpty())){
            users1.forEach(System.out::println);
        }
            //从新创建一个选择器  删除年龄小于22岁的


    }
}
